package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Map;

@WebServlet("/demo")
public class DemoServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       /* String username = req.getParameter("username");
        String pwd = req.getParameter("pwd");
        System.out.println("ajax  请求！！！"+username+pwd);
        //int i=1/0;


        String qs = req.getQueryString();
        System.out.println("queryString:"+qs);*/


        BufferedReader reader = req.getReader();
        //System.out.println("ssss:"+reader.readLine());
        String str="";
        while ((str=reader.readLine())!=null){
            System.out.println("reader:"+str);
        }


   /*     Map<String, String[]> parameterMap = req.getParameterMap();
        System.out.println(parameterMap.size());
*/

        //向客户端响应数据
        //设置请求的字符集编码
        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write("黑马");
    }
}
